#ifndef ADMINWIDGET_H
#define ADMINWIDGET_H

#include <QTabWidget>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlQueryModel>
#include <QSqlTableModel>
#include <QSqlError>
#include <QString>
#include <QMessageBox>
#include <QListWidgetItem>
#include <QTableWidgetItem>
#include <QItemSelectionModel>
#include <QSettings>
#include <QDate>
#include <QDateEdit>
#include <QGraphicsScene>
#include <QGraphicsTextItem>
#include <QFileDialog>

#include <QDebug>


#include <Clavier/clavier.h>
#include <ClavNum/clavnum.h>
#include <pg.h>
#include <mdpdialog.h>
#include <mvtdialog.h>
#include <moduleaccueil.h>
#include <dialogimporter.h>
#include <dialogtransfert.h>

namespace Ui {
class AdminWidget;
}

class AdminWidget : public QTabWidget
{
    Q_OBJECT
    
public:
    explicit AdminWidget(QWidget *parent = 0);
    ~AdminWidget();

    //adminwidget.cpp

public slots:

signals:
    void changementAccueil();
    void reconnecterBase();

private slots:


    //page PG
    void on_buttonPgCreer_clicked();
    void on_buttonPgClore_clicked();
    void on_buttonPgValider_clicked();
    void on_buttonPgRetour_clicked();
    void on_linePgFams_textEdited(QString text);
    void on_listPgProms_itemClicked(QListWidgetItem* it);
    void actualiserListPgConsos(Pg pg);
    void on_radioPgConsos_toggled(bool checked);
    void on_buttonPgModifier_clicked();
    void on_linePgBucque_textEdited(const QString &arg1);
    void on_comboPgStatus_currentIndexChanged(int index);
    void majInfosPg(Pg pg = Pg());

    //page RA
    void on_spinRAZidentFams_valueChanged(int i);

    //page Remise
    void on_buttonRemiseSession_clicked();
    void on_buttonRemiseAnnuler_clicked();
    void on_spinRemiseSessionFams_valueChanged(int i);
    void on_comboRemiseProms_currentIndexChanged(const QString &arg1);
    void on_spinRemiseMontant_valueChanged(double arg1);
    void on_buttonRemiseReset_clicked();
    void on_tableSessionRemise_itemClicked(QTableWidgetItem *item);
    void on_buttonRemiseAjouter_clicked();
    void majListeRemise();
    void on_buttonRemiseValider_clicked();
    void on_buttonRemiseSupprimer_clicked();

    //page Agios
    void on_buttonAgiosNouveau_clicked();
    void on_buttonAgiosRetour_clicked();
    void majListAgios(QStringList l= QStringList());
    void majAgiosPgs();
    void majAgiosProms();
    void on_buttonAgiosSupprimer_clicked();
    void on_listAgiosProms_clicked(const QModelIndex &index);
    void on_buttonAgiosAppliquer_clicked();

    //page Consos
    void on_buttonConsosAjouter_clicked();
    void on_buttonConsosNouveau_clicked();
    void on_listConsosMotsClefs_itemClicked(QListWidgetItem *item);
    void on_buttonConsosModifier_clicked();
    void on_lineConsosInfosIntitule_textEdited(const QString &arg1);
    void on_spinConsosInfoPrix_editingFinished();
    void on_listConsos_clicked(const QModelIndex &index);
    void on_lineConsosRecherche_textChanged(const QString &arg1);
    void on_buttonConsosMvtDispo_clicked();
    void on_buttonConsosMvtReserve_clicked();
    void majInfosConsos();
    bool verifieIntitule();
    void on_buttonConsoStat_clicked();
    void on_buttonStatFermer_clicked();
    void majStat();
    void majDuree();
    void on_dateConsoDu_editingFinished();
    void on_dateConsoAu_editingFinished();
    void on_radioConsosDureeMois_toggled(bool checked);
    void on_radioConsosTypeConso_toggled(bool checked);

    //page Admin
    void on_buttonAdminRetour_clicked();
    void on_plainTextEdit_textChanged();
    void on_checkAdminTactile_clicked(bool checked);
    void on_checkAdminStock_clicked(bool checked);
    void on_buttonAdminQuitter_clicked();
    void on_buttonAdminMdp_clicked();


    void on_buttonAdminAppliquer_clicked();

    void on_buttonConsosSupprimer_clicked();

    void on_buttonMBImporter_clicked();

    void on_buttonAdminTransfert_clicked();

    void on_spinAgiosRecherche_valueChanged(int arg1);

    void on_comboAgiosRecherche_currentTextChanged(const QString &arg1);

    void on_pushButton_clicked();

private:
    Ui::AdminWidget *ui;
    QSqlDatabase db;
    QSqlQueryModel *modelPgHistorique;
    QSqlQueryModel *modelRemise;
    QSqlQueryModel *modelAgios;
    QSqlQueryModel *modelAgiosPgs;
    QSqlQueryModel *modelAgiosProms;
    QSqlTableModel *modelConsos;
    QGraphicsScene *scene;
    QItemSelectionModel *selectionModel;

    Clavier *clavierPg;
    Clavier *clavierConsos;
    Clavier *clavierAdmin;
    ClavNum *padAdmin;
    ClavNum *padPg;
    ClavNum *padRA;
    ClavNum *padConsos;

    QDateEdit *dernierModifier;

    int idConsoCourante;
    bool tactile;
    bool gestionStocks;

};

#endif // ADMINWIDGET_H
